package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) {
        try(
                Connection con=DBUtil.getConnection();
                ) {
            String sql="UPDATE userinfo "+
                    "SET password='66666' "+
                    "WHERE username='王克晶' ";
            Statement sa=con.createStatement();
            int num=sa.executeUpdate(sql);
            if (num>0){
                System.out.println("修改成功");
            }else {
                System.out.println("修改失败");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        try(
                Connection con=DBUtil.getConnection();
                ) {
            String sql="DELETE FROM userinfo WHERE username='范传奇'";
            Statement sa=con.createStatement();
            int num=sa.executeUpdate(sql);
            if (num>0) {
                System.out.println("修改成功");
            } else {
                System.out.println("修改失败");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
